import Vue from 'vue'
import Vuex from 'vuex'
import { getTableData, pageData } from '../api/index'
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    tableData: [],
    pageList: [],
    total: 0
  },
  // action: { type:  }
  mutations: {
    ['GET_INIT_DATA'](state, data) {
      state.tableData = data;
    },
    ['GET_PAGE_DATA'](state, data) {
      state.pageList = data.data;
      state.total = data.total;
    }
  },
  actions: {
    getInitData({ commit }) {
      getTableData().then(res => {
        commit('GET_INIT_DATA', res.data)
      })
    },
    getPageData({ commit }, params) {
      pageData({ ...params }).then(res => {
        commit('GET_PAGE_DATA', res)
      })
    },
  },
  getter: {

  },
  modules: {
  }
})
